const app = getApp()
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    label: {
      type: String
    },
    value: {
      type: String,
    },
    placeholder: {
      type: String
    },
    checked: {
      type: Boolean
    },
    types:{
      type:null
    },
    issum:{
      type:Number
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    customValue: '',
    hospitalDepartList:[]
  },

  /**
   * 组件的方法列表
   */
  methods: {
    bindblur(e) {
      let value = e.detail.value
      this.setData({
        customValue: value,
        hospitalDepartList:[]
      })
      if (this.validate()) {
        this.triggerEvent('change', {
          label: this.data.label,
          value: value
        })
      }
    },
    validate () {
      let value = this.data.customValue
      if(this.data.types==0){
        if (value < 3 || value > 50) {
          app.showMsg('自定义天数最低3天，最高50天。')
          return false
        }
      }else{
        if (value < 1 || value > 8) {
          app.showMsg('自定义最低1小时，最高8小时。')
          return false
        }
      }
      
      return true
    },
    bindtapRadio() {
      this.getkslist(this.data.value)
      // this.triggerEvent('change', {
      //   label: this.data.label,
      //   value: this.data.value
      // })
    },
    getkslist(id){
      let that = this
      wx.request({
        url: app.globalData.serverUrlgdb + '/hosPart/list/by/'+id,
          method: 'get',
          header: {
          'token': wx.getStorageSync('token')
        },
        success:res=>{
          let resp = res.data
          if(resp.code == 200){
            that.setData({
              hospitalDepartList:resp.data.hospitalDepartList
            })
            console.log(resp.data,'科室');
          }
        }
      })
    },
  },
})